package com.sg.business.permission;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.bson.types.ObjectId;

import com.mobnut.db.model.ModelService;
import com.sg.business.model.Document;
import com.sg.business.permission.adapter.doc.DocumentACL;

public class ReloadPermissionService extends HttpServlet {

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		doPost(req, resp);
	}

	@Override
	protected void doPost(HttpServletRequest request, HttpServletResponse resp)
			throws ServletException, IOException {
		String id = request.getParameter("id"); //$NON-NLS-1$
		ObjectId _id = new ObjectId(id);
		Document document = ModelService.createModelObject(Document.class, _id);
		new DocumentACL(document).reloadPermission();
	}
}
